package org.hfy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 报价单状态枚举
 * 
 * @author hfy
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum QuotationStatusEnum {
    
    DRAFT("DRAFT", "草稿"),
    SUBMITTED("SUBMITTED", "已提交"),
    CONTRACT_GENERATED("CONTRACT_GENERATED", "已生成合同"),
    AUDITED("AUDITED", "已审核"),
    REJECTED("REJECTED", "已拒绝");
    
    private final String code;
    private final String description;
    
    /**
     * 根据代码获取枚举
     */
    public static QuotationStatusEnum fromCode(String code) {
        for (QuotationStatusEnum status : QuotationStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的报价单状态代码: " + code);
    }
    
    /**
     * 根据描述获取枚举
     */
    public static QuotationStatusEnum fromDescription(String description) {
        for (QuotationStatusEnum status : QuotationStatusEnum.values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的报价单状态描述: " + description);
    }
} 